#!/bin/bash

old_pid=$(ps -ef | grep 'router_test.py' | grep -v 'grep' | awk '{print $2}')

if [ ! -z "$old_pid" ]; then
  echo "Killing existing service with PID $old_pid"
  kill -9 $old_pid
fi

nohup python3 /home/formula2code/latex2code/router_test.py > /home/formula2code/output.log 2>&1 &

new_pid=$!
echo "New service started with PID $new_pid"

